//footer_8d5b425

_.Module.define({
	path: "frs-footer/pagelet/content_footer",
	sub: {
		initial: function(t) {
			var e = $(".editor_wrap_bright");
			t && t.on("tab_change", function(t) {
				var o = t.tab || "frs";
				"frs" === o ? e.show() : e.hide()
			})
		}
	}
});
_.Module.define({
	path: "entertainment-game/widget/duoku_servers_dialog",
	requires: ["tbui/widget/tbcopy"],
	sub: {
		_dialog_tmp: {
			fail_html: ['<div class="comforum_duoku_servers_dialog">', '<!--div class="fail_img"></div-->', '<div class="duoku_servers_qrcode_wrapper">', '<div class="qrcode_content"></div>', "<p>\u626b\u63cf\u4e8c\u7ef4\u7801\u4e0b\u8f7d\u6e38\u620f</p>", "</div>", '<div class="qrcode_right_area">', "<p>\u5df2\u88ab#{code_label}\u5149\u4e86\uff0c\u4f46\u53ef\u4ee5\u7ee7\u7eed\u4e0b\u8f7d\u54e6~</p>", '<div class="btns">', '<a href="#{button_url}" class="j_duoku_download btn_default btn_middle" target="_blank">', "<span><em>\u7acb\u5373\u4e0b\u8f7d</em></span>", "</a>", "</div>", "</div>", "</div>"].join(""),
			cong_html: ['<div class="comforum_duoku_servers_dialog">', '<div class="duoku_servers_qrcode_wrapper">', '<div class="qrcode_content"></div>', "<p>\u626b\u63cf\u4e8c\u7ef4\u7801\u4e0b\u8f7d\u6e38\u620f</p>", "</div>", '<div class="qrcode_right_area">', "<p>\u60a8\u5df2\u7ecf#{code_label}\uff0c\u8d76\u7d27\u4e0b\u8f7d\u6e38\u620f\u5f00\u59cb\u5427</p>", '<p class="duoku_code j_duoku_code">#{code_title}\uff1a<span class="j_duoku_code_value duoku_code_value">#{game_code}</span></p>', '<div class="btns">', '<button class="j_duoku_copy duoku_copy btn_default btn_middle"><span><em>\u590d\u5236#{code_title}</em></span></button>', '<a href="#{button_url}" class="j_duoku_download btn_default btn_middle" target="_blank">', "<span><em>\u7acb\u5373\u4e0b\u8f7d</em></span>", "</a>", "</div>", "</div>", "</div>"].join(""),
			hadcode_html: ['<div class="comforum_duoku_servers_dialog">', '<div class="duoku_servers_qrcode_wrapper">', '<div class="qrcode_content"></div>', "<p>\u626b\u63cf\u4e8c\u7ef4\u7801\u4e0b\u8f7d\u6e38\u620f</p>", "</div>", '<div class="qrcode_right_area">', "<p>\u60a8\u5df2\u7ecf#{code_label}\uff0c\u8d76\u5feb\u4e0b\u8f7d\u5427\u3002</p>", '<p class="duoku_code j_duoku_code">#{code_title}\uff1a<span class="j_duoku_code_value duoku_code_value">#{game_code}</span></p>', '<div class="btns">', '<button class="j_duoku_copy duoku_copy btn_default btn_middle"><span><em>\u590d\u5236#{code_title}</em></span></button>', '<a href="#{button_url}" class="j_duoku_download btn_default btn_middle" target="_blank">', "<span><em>\u7acb\u5373\u4e0b\u8f7d</em></span>", "</a>", "</div>", "</div>", "</div>"].join("")
		},
		initial: function() {},
		showDialog: function(e) {
			this.game = e.game, this.postTrack = e.postTrack, this.src = e.src, this.tbs = e.tbs, this._getCode()
		},
		_getCode: function() {
			var e = this,
				o = "/game/duoku/applyToPlay",
				d = this.game,
				t = d.game_id,
				a = d.game_name,
				_ = d.kaifu_id;
			this.postTrack("\u83b7\u53d6\u8d44\u683c", d), d && $.post(o, {
				game_id: t,
				kaifu_id: _,
				game_name: a,
				tbs: this.tbs,
				src: this.src
			}, function(o) {
				var t = o.data && (o.data.game_code || o.data.gift_code),
					a = o.no;
				d.applied && (a = 2), d.code_title = d.check_code ? "\u6d4b\u8bd5\u7801" : d.gift_code ? "\u793c\u5305\u7801" : "\u6d4b\u8bd5\u7801", d.code_label = d.check_code ? "\u62a2\u5230\u4e86\u6d4b\u8bd5\u8d44\u683c" : d.gift_code ? "\u9886\u53d6\u4e86\u6e38\u620f\u793c\u5305" : "\u62a2\u5230\u4e86\u6d4b\u8bd5\u8d44\u683c", 0 == a ? (e.postTrack("\u62a2\u53f7\u6210\u529f\u6d6e\u5c42\u5c55\u793a", d, {}, "view"), e._showDialog("cong_html", "\u606d\u559c\u60a8", d, t)) : 1 == a ? (d.code_label = d.gift_code ? "\u9886" : "\u62a2", e.postTrack("\u5931\u8d25\u6d6e\u5c42\u5c55\u793a", d, {}, "view"), e._showDialog("fail_html", "\u5f88\u9057\u61be... ...", d, t)) : 2 == a ? (e.postTrack("\u5df2\u62a2\u8fc7\u53f7\u6d6e\u5c42\u5c55\u793a", d, {}, "view"), e._showDialog("hadcode_html", "\u60a8\u5df2\u7ecf\u62a2\u8fc7\u55bd~", d, t)) : 4 == a ? e.requireInstanceAsync("common/widget/LoginDialog", ["", "userBar"]) : alert("\u670d\u52a1\u5668\u62bd\u98ce")
			})
		},
		_showDialog: function(e, o, d, t) {
			var a = new $.dialog({
				html: $.tb.format(this._dialog_tmp[e], {
					button_url: d.button_url,
					game_name: d.game_name,
					game_code: t,
					code_label: d.code_label,
					code_title: d.code_title
				}),
				title: o,
				width: 436,
				height: 156,
				draggable: !1,
				closeable: !0
			});
			$.JsLoadManager.use("//tb1.bdstatic.com/tb/static-entertainment-game/qrcode_665d0df.js", function() {
				new window.QRCode($(".comforum_duoku_servers_dialog .qrcode_content")[0], {
					text: d.download_url,
					width: 128,
					height: 128
				})
			}), t && (a.element.find(".j_duoku_copy, .j_duoku_code").show(), this.tbcopy ? this.tbcopy.add(a.element.find(".j_duoku_copy")) : this.tbcopy = this.requireInstance("tbui/widget/tbcopy", {
				ele: a.element.find(".j_duoku_copy")
			}), this.tbcopy.setText($(".comforum_duoku_servers_dialog .j_duoku_code_value").text()));
			var _ = this;
			a.element.on("click", ".j_duoku_download", function() {
				_.postTrack("", d, "", "download")
			}), a.element.on("click", ".j_duoku_copy", function() {
				_.postTrack("\u590d\u5236\u6309\u94ae", d)
			})
		}
	}
});
_.Module.define({
	path: "entertainment-game/widget/duoku_servers_list",
	requires: ["entertainment-game/widget/duoku_servers_dialog"],
	sub: {
		_btn_list_tmp: {
			get_code: ['<li class="j_dsh_game" data-index="#{index}">', '<a href="#{thread_url}" target="_blank"><img src="#{icon_url}"></a>', '<span class="game_title"><a href="#{thread_url}" target="_blank">#{game_name}</a></span>', '<a href="#{get_code_action}" target="_blank" class="get_code_btn">', '<div class="#{platform_class} get_code_icon"></div>', "<span>#{apply_text}</span>", "</a>", "</li>"].join("")
		},
		locateMap: {
			frs: "p0117",
			pb: "p0118"
		},
		initial: function(e) {
			this.redirectUrl = e.redirectUrl, this.$wrapper = $("#duoku_servers_list");
			var t = this;
			this._loader().done(function(e) {
				t._render(e.data), t.dialog = t.requireInstance("entertainment-game/widget/duoku_servers_dialog")
			}), this._bindEvents()
		},
		_loader: function() {
			var e = "/game/duoku/getHotGames?timestamp=" + (new Date).getTime(),
				t = $.getJSON(e);
			return t
		},
		_formatRedirectUrl: function(e, t) {
			for(var a = e.split("?"), r = a[0], i = a[1].split("&"), n = {}, o = [], d = 0, _ = i.length; _ > d; d++) {
				var l = i[d],
					s = l.split("=")[0],
					c = l.split("=")[1];
				n[s] = c
			}
			n._t = +new Date, t && (delete n.client_type, delete n.refer, delete n.url, delete n.url, delete n.fid, delete n.fname, delete n.page, delete n.type, delete n.ie);
			for(var g in n) n.hasOwnProperty(g) && n[g] && o.push(g + "=" + n[g]);
			return ["http://", $.tb.location.getHost(), r, "?", o.join("&")].join("")
		},
		getRedirectUrl: function(e, t, a, r, i, n) {
			var o = [this._formatRedirectUrl(this.redirectUrl, n), "location=p0012", "obj_ref=3000601", "obj_id=" + i, "obj_name=" + encodeURIComponent(r), "type=" + a, "tbjump=" + encodeURIComponent(e), "loc_param=" + t].join("&");
			return o
		},
		_render: function(e) {
			e = e || [], this.games = e, 0 == this.games.length && this.$wrapper.hide();
			var t = this.$wrapper.find(".servers_list_wrapper"),
				a = "",
				r = e.length;
			r = r > 7 ? 7 : r;
			for(var i, n = 0; r > n; n++) {
				var o = e[n];
				o.qrcode_url = this.getRedirectUrl(o.redirect_url, "qr_code", "download", o.game_name, o.game_id, !0), o.button_url = this.getRedirectUrl(o.redirect_url, "button", "click", o.game_name, o.game_id), i = "android" == o.supported_os.toLowerCase() ? "get_code_android" : "get_code_iphone", a += $.tb.format(this._btn_list_tmp.get_code, {
					game_name: o.game_name,
					thread_url: o.thread_url,
					icon_url: o.icon_url,
					platform_class: i,
					apply_text: o.applied ? "\u5df2\u9886\u53d6" : o.not_available ? "\u5e93\u5b58\u544a\u6025" : o.check_code ? "\u83b7\u53d6\u8d44\u683c" : o.gift_code ? "\u9886\u53d6\u793c\u5305" : "-1" == o.download_url ? "\u4e86\u89e3\u8be6\u60c5" : "\u7acb\u5373\u4e0b\u8f7d",
					get_code_action: o.applied || o.not_available || o.check_code || o.gift_code ? "javascript:;" : "-1" == o.download_url ? o.thread_url : o.download_url,
					index: n
				})
			}
			t.html(a)
		},
		_bindEvents: function() {
			var e = this;
			this.$wrapper.on("click", ".get_code_btn", function(t) {
				if("javascript:;" == $(t.currentTarget).tbattr("href")) e._getGameCode(t);
				else {
					var a = $(t.currentTarget).closest(".j_dsh_game").tbattr("data-index"),
						r = e.games[a];
					e._postTrack("", r, "", "download")
				}
			}), this.$wrapper.on("click", ".servers_detail_link", function() {
				e._postTrack("\u66f4\u591a\u94fe\u63a5")
			})
		},
		_getGameCode: function(e) {
			var t = this,
				a = $(e.currentTarget).closest(".j_dsh_game").tbattr("data-index"),
				r = this.games[a];
			return t.dialog.showDialog({
				tbs: PageData.tbs,
				game: r,
				postTrack: $.proxy(t._postTrack, t),
				src: "list"
			}), !1
		},
		_postTrack: function(e, t, a, r) {
			e || (e = this.locateMap[PageData.product]), "undefined" == typeof r && (r = "click"), a = a || {}, a = $.extend({
				obj_ref: 3000603
			}, a), t && (a = $.extend({
				obj_name: t.game_name,
				obj_game_id: t.game_id
			}, a)), $.stats.track(e, "mg_pioneerba", "", r, a)
		}
	}
});
_.Module.define({
	path: "common/widget/footer",
	sub: {
		initial: function() {
			this._handleEvents()
		},
		_handleEvents: function() {
			var i = $("#btnFroceToPad");
			i.bind("click", function() {
				$.cookie("tb_device", null);
				var i = window.location.href.toString(); - 1 !== i.indexOf("kw") && -1 === i.indexOf("ie=utf-8") && (i += -1 !== i.indexOf("?") ? "&ie=utf-8" : "?ie=utf-8"), $.tb.location.setHref(i)
			})
		}
	}
});